import request from '@/utils/request';

// 获取列表
export function getDataList(data) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottEquipment/getListByPage',
    method: 'post',
    data: data
  });
}

// 创建或者编辑
export function saveDevice(data) {
  let url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottEquipment/create';
  if (data.objectId || data.objectId == 0) {
    url = process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottEquipment/update';
  }
  return request({
    url: url,
    method: 'post',
    data: data
  });
}

// 删除选中数据
export function deleteSelectedData(ids) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottEquipment/deleteByList',
    method: 'post',
    data: {
      keyValues: ids
    }
  });
}

// 设备关联车辆
export function setCar(params) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/related',
    method: 'post',
    data: params
  });
}

// 删除选中数据
export function cancelSelectedData(ids) {
  return request({
    url: process.env.VUE_APP_BUS_SERVICE_NAME + 'api/ottVehicleInfo/unRelated',
    method: 'post',
    data: {
      equipmentIds: ids
    }
  });
}
